<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                >

    <f:subview id="cadastroQuestaoVersaoEmbutido" rendered="#{fluxoExibicaoCadastro.exibirCadastroQuestaoVersao}">
        <h:panelGrid columns="1" id="embCadQuesVer" width="850" styleClass="center">
            <h:panelGroup id="grupCadQuestaoVer" styleClass="esquerda" >
                  <h:form id="formTableQuestoes">
                    <p:dataTable value="#{cadastroQuestaoVersao.questoesModel}" var="questao" id="tableQuestoes" rows="5" paginator="true"
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks}
                                 {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" styleClass="bvb-font"
                                 rowsPerPageTemplate="5,10,15" emptyMessage="#{msg.semRegistrosEcontrados}" 
                                 >
                        <f:facet name="header">
                            <h:outputText value="#{msg.richTableQuestoes}"/>
                        </f:facet>

                        <p:column id="col1" styleClass="center" style="width: 45px;" filterBy="#{questao.id}" 
                                  headerText="Model" footerText="contains" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="#{msg.richColumnId}"/>
                            </f:facet>
                            <h:outputText value="#{questao.id}" styleClass="bvb-font"/>
                        </p:column>

                        <p:column id="col2" filterBy="#{questao.enunciado}" headerText="Model" footerText="contains"
                                  filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="#{msg.richColumnEnunciado}"/>
                            </f:facet>
                            <h:inputTextarea cols="25" rows="3" disabled="true" value="#{questao.enunciado}" style="font-size: 10px;"/>
                        </p:column>

                        <p:column id="col8" filterBy="#{questao.objetivoCertificacao}" headerText="Model" footerText="contains"
                                  filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="#{msg.richColumnObjetivo}" />
                            </f:facet>
                            <h:inputTextarea cols="25" rows="3" disabled="true" value="#{questao.objetivoCertificacao}" style="font-size: 10px;"/>
                        </p:column>

                        <p:column id="col7" styleClass="center"  filterBy="#{questao.professorResponsavel.nomeSobreNome}"
                                  headerText="Model" footerText="contains" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="#{msg.richColumnCadastrante}"/>
                            </f:facet>
                            <h:outputText value="#{questao.professorResponsavel.nomeSobreNome}" styleClass="bvb-font"/>
                        </p:column>

                        <p:column id="col10" styleClass="center" filterBy="#{questao.versoesString}" headerText="#{msg.richColumnVersoes}" 
                                  filterMatchMode="contains" >
                            <f:facet name="header">
                                <h:outputText value="#{msg.richColumnVersoes}"/>
                            </f:facet>
                            <h:outputText value="#{questao.versoesString}" styleClass="bvb-font"/>
                        </p:column>

                        <p:column id="col9" styleClass="center" style="width: 65px;">
                            <f:facet name="header">
                                <h:outputText value="#{msg.richColumnEditar}"/>
                            </f:facet>
                            <p:commandLink update="conteudoCentralGroup,messages" title="#{msg.titleButtonPegaQuestaoVersao}" 
                                           id="buttonEditar" styleClass="ui-button_link">
                                <h:graphicImage library="img" name="questao_24_edit.png"/>
                                <f:setPropertyActionListener value="#{questao}" target="#{cadastroQuestaoVersao.questaoManipulada}" />  
                            </p:commandLink>
                        </p:column>
                    </p:dataTable>
                </h:form>
                
                <p:spacer width="100%" height="15"/>
                
                <h:form id="formCadQuestaoVer" styleClass="formularioFundo" rendered="#{cadastroQuestaoVersao.questaoManipulada != null}">
                    <h:panelGrid columns="3" styleClass="bvb-font">
                        <f:facet name="header">
                            <h:outputText value="#{msg.cadQuestaoVersaoPanelGridTitle}" styleClass="formularioTitle"/>
                        </f:facet>
                        <h:outputLabel value="#{msg.certificacao}:" id="labelCertificacao" title="#{msg.titleCertificacaoQuestao}"/>
                        <h:inputText value="#{cadastroQuestaoVersao.certificacaoQuestao.certificacaoLabel}" disabled="true" size="30" id="certificacaoDisable"/>
                        <h:panelGroup>
                            <p:message for="certificacaoDisable"/>
                        </h:panelGroup>

                        <h:outputLabel value="#{msg.objetivoCertificacao}:" id="labelObjetivoCertificacao" title="#{msg.titleObjetivoCertificacao}"/>
                        <p:autoComplete value="#{cadastroQuestaoVersao.questaoManipulada.objetivoCertificacao}"
                                        id="inputObjetivoCertificacao" required="true" minQueryLength="3" completeMethod="#{cadastroQuestaoVersao.shooser}" 
                                        size="70" requiredMessage="#{msg.campoObrigatorio}" disabled="#{cadastroQuestaoVersao.questaoManipulada == null}"
                                        title="#{msg.titleObjetivoCertificacao}" label="#{msg.objetivoCertificacao}"
                                        onkeyup="Contar(this.value, 'promsg', 150)">
                            <f:validateLength minimum="5" maximum="150"/>
                        </p:autoComplete>
                        <h:panelGroup>
                            <span id="promsg"></span><br></br>
                            <p:message for="inputObjetivoCertificacao"/>
                        </h:panelGroup>


                        <h:outputLabel value="#{msg.enunciado}:" id="labelEnunciado" title="#{msg.titleEnunciadoQuestao}"/>
                        <h:inputTextarea value="#{cadastroQuestaoVersao.questaoManipulada.enunciado}" 
                                         disabled="#{cadastroQuestaoVersao.questaoManipulada == null}"
                                         cols="80" rows="3" id="inputEnunciado" title="#{msg.titleEnunciadoQuestao}"
                                         required="true" requiredMessage="#{msg.campoObrigatorio}"
                                         label="#{msg.enunciado}" onkeyup="Contar(this.value, 'enumsg', 2000)">
                            <f:validateLength minimum="5" maximum="2000"/>
                        </h:inputTextarea>
                        <h:panelGroup>
                            <span id="obsmsg"></span><br></br>
                            <p:message for="inputEnunciado"/>
                        </h:panelGroup>

                        <h:outputLabel value="#{msg.observacao}:" id="labelObservacao" title="#{msg.titleObservacaoQuestao}" />
                        <h:inputTextarea value="#{cadastroQuestaoVersao.questaoManipulada.observacao}" 
                                         disabled="#{cadastroQuestaoVersao.questaoManipulada == null}"
                                         cols="80" rows="2" id="inputObservacao" requiredMessage="#{msg.campoObrigatorio}"
                                         label="#{msg.observacao}" onkeyup="Contar(this.value, 'obsmsg', 255)"
                                         required="true" title="#{msg.titleObservacaoQuestao}">
                            <f:validateLength minimum="5" maximum="255"/>
                        </h:inputTextarea>
                        <h:panelGroup>
                            <span id="obsmsg"></span><br></br>
                            <p:message for="inputObservacao"/>
                        </h:panelGroup>

                        <h:outputLabel value="#{msg.idioma}:" id="labelIdioma" title="#{msg.titleIdiomaQuestao}"/>
                        <h:selectOneMenu value="#{cadastroQuestaoVersao.questaoManipulada.linguagem}" id="selectLinguagem"
                                         required="true" requiredMessage="#{msg.campoObrigatorio}"
                                         disabled="#{cadastroQuestaoVersao.questaoManipulada == null}"
                                         label="#{msg.idioma}">
                            <f:converter converterId="linguagemConverter"/>
                            <f:selectItem itemLabel="#{msg.selecione}" itemValue=""/>
                            <f:selectItems value="#{cadastroQuestaoVersao.linguagens}"/>
                        </h:selectOneMenu>
                        <p:message for="selectLinguagem"/>


                        <h:outputLabel value="#{msg.registroNecessario}:" id="labelRegistroNecessario" title="#{msg.titleResgistradosQuestao}"/>
                        <p:selectBooleanCheckbox value="#{cadastroQuestaoVersao.questaoManipulada.registradosQuestao}" id="selectRegistroNecessario"
                                                 label="#{msg.registroNecessario}" disabled="#{cadastroQuestaoVersao.questaoManipulada == null}">
                        </p:selectBooleanCheckbox>
                        <p:message for="selectRegistroNecessario"/>

                        <h:outputLabel value="#{msg.tipoQuestao}:" id="labelTipoQuestao" title="#{msg.titleTipoQuestaoQuestao}"/>
                        <p:selectOneRadio value="#{cadastroQuestaoVersao.questaoManipulada.tipoQuestao}" id="selectTipoQuestao"
                                          required="true" styleClass="bvb-font"
                                          requiredMessage="#{msg.campoObrigatorio}"
                                          disabled="#{cadastroQuestaoVersao.questaoManipulada == null}"
                                          label="#{msg.tipoQuestao}">
                            <f:selectItems value="#{cadastroQuestaoVersao.tipoQuestoes}"/>
                            <f:converter converterId="tipoQuestaoConverter"/>
                        </p:selectOneRadio>
                        <p:message for="selectTipoQuestao"/>

                        <h:outputText value="#{msg.versao}:"/>
                        <p:selectManyCheckbox  value="#{cadastroQuestaoVersao.versoesSelecionadas}"  id="piklistInput" layout="pageDirection"
                                               label="#{msg.versao}" disabled="#{cadastroQuestaoVersao.questaoManipulada == null}"
                                               style="height:100px;" required="true" requiredMessage="#{msg.campoObrigatorio}">   
                            <f:converter converterId="genericoConverter"/>
                            <f:selectItems value="#{cadastroQuestaoVersao.versoesItem}"  />  
                        </p:selectManyCheckbox > 
                        <h:panelGroup>
                            <p:message for="piklistInput"/>
                        </h:panelGroup>

                        <h:outputText value=""/>
                        <p:commandLink actionListener="#{cadastroQuestaoVersao.salvarQuestao}" update="conteudoCentralGroup,messages"
                                       id="buttonQuestaoVerAtualizar" styleClass="ui-button_link" title="#{msg.titleButtonSalvarQuestao}">
                            <h:graphicImage library="img" name="bt_salvar.png"/>
                        </p:commandLink>
                    </h:panelGrid>
                </h:form>

                
            </h:panelGroup>
        </h:panelGrid>

    </f:subview>
</ui:composition>